Structures (Cont.)
Pascal C/C++
wvar
w borrower: record
w id: integer;
w name: packed array[1..10] of char;
w case boolean of
w false: (EBorr: emploee);
w true: (SBorr: student)
w end;
wstruct
w{    int id;
w     char name[11];
w     union
w     {   emploee EBorr;
w         student SBorr;
w      } Borr;
w} borrower;
The variants can be accessed as
borrower.EBorr;                    borrower.Borr.EBorr;
borrower.Sborr                      borrower.Borr.SBorr
C++ only:
The field name Borr for the union can be omitted; the variants can then be referenced as in Pascal.